﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>码农阿川 | 注册</title>
    
    <link href="~/Content/bootstrap.min.css" rel="stylesheet" />
    <link href="~/Content/font-awesome/css/font-awesome.min.css" rel="stylesheet" />
    <link href="~/Content/plugins/iCheck/custom.css" rel="stylesheet" />
    <link href="~/Content/animate.css" rel="stylesheet" />
    <link href="~/Content/style.css" rel="stylesheet" />

</head>

<body class="gray-bg">

    <div class="middle-box text-center loginscreen   animated fadeInDown">
        <div>
            <p>欢迎您，少年，注册吧。</p>
            <form class="m-t" role="form">
                <div class="form-group">
                    <input type="text" id="userName" class="form-control" placeholder="用户名" required="">
                </div>
                <div class="form-group">
                    <input type="password" id="password" class="form-control" placeholder="密码" required="">
                </div>
   
                <button type="button" id="btnRegister" onclick="register()" class="btn btn-primary block full-width m-b">注册</button>

                <p class="text-muted text-center"><small>已经有一个账号?</small></p>
                <a class="btn btn-sm btn-white btn-block" href="/admin/account/logon">登录</a>
            </form>
            <p class="m-t"> <small>仰望星空，脚踏实地。帮助他人，成就自我。</small> </p>
        </div>
    </div>

    <!-- Mainly scripts -->
    <script src="~/Scripts/jquery-2.1.1.js"></script>
    <script src="~/Scripts/bootstrap.min.js"></script>
    <script type="text/javascript">
        function register() {
            var userName = $("#userName").val();
            if (userName == "") {
                $("#userName").focus();
                return;
            }
            var password = $("#password").val();
            if (password == "") {
                $("#password").focus();
                return;
            }
            var data = {
                UserName: userName,
                Password: password
            };
            var url = "/admin/api/account/register";

            $.ajax({
                type: "post",
                url: url,
                data: data,
                dataType: "json",
                success: function (result) {
                    if (!result.iserror) {
                        window.location = "/admin/account/logon";
                        return;
                    }
                    alert(result.message);
                }
            });
        }
    </script>

</body>
</html>